﻿using Simulation.Framework;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace Easy.Game2d {

    public partial class UILevelPanel : PanelBase {

        #region override
        public override void Init(params object[]  data) {
            InitComponent();
        }

        public override void Clear() {
            ClearComponent();
        }

        public override void Open() {
            gameObject.SetActive(true);
        }

        public override void Close() {
            gameObject.SetActive(false);
        }
        #endregion

        #region data
        private Coroutine _waitCor;
        #endregion

        #region logic
        public void SetLevel(int value)
        {
            LevelTextTextMeshProUGUI.text = string.Format("第{0}关卡", value);
            UIPlayStatePanle playStatePanle= SingleBehavior<PanelManager>.getInstance().Open<UIPlayStatePanle>(PanelName._playStatePanle);
            playStatePanle.NumberLayersTextMeshProUGUI.text= string.Format("第{0}关卡", value);
            if (_waitCor != null) StopCoroutine(_waitCor);
            _waitCor=StartCoroutine(WaitHide());
        }
        private IEnumerator WaitHide()
        {
            yield return new WaitForSeconds(2);
            Close();
        }
        #endregion
    }
}
